﻿//===============================================================================
// Microsoft patterns & practices
// Composite Application Guidance for Windows Presentation Foundation
//===============================================================================
// Copyright (c) Microsoft Corporation.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System.Windows;
using Microsoft.Practices.Unity;
using PJ.Framework.Common;
using PJ.Business.Partner;
using PJ.Business.SalePurchase.Sale;
using PJ.Presentation.SalePurchase.Sale;
using Microsoft.Practices.Composite.Events;
using PJ.Presentation.Partner;
using PJ.Data.Inventory;
using PJ.Data.SalePurchase.Sale;
using PJ.Data.Partner;
using Microsoft.Practices.EnterpriseLibrary.Caching;
using PJ.Business.Inventory;
using PJ.Operation.SalePurchase.Sale;
using PJ.Framework;
using Microsoft.Practices.Composite.Modularity;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.Composite.Logging;
using Microsoft.Practices.EnterpriseLibrary.Logging.Configuration.Unity;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Unity;
using Microsoft.Practices.EnterpriseLibrary.Caching.Configuration.Unity;

namespace PJ.AppPOS
{
    internal class Bootstrapper : Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper
    {
        protected override IModuleCatalog GetModuleCatalog()
        {
            return new ConfigurationModuleCatalog()
                            .AddModule(typeof(PJ.Presentation.Partner.CustomerModule))
                            .AddModule(typeof(PJ.Presentation.SalePurchase.Sale.ShoppingCartModule));
        }

        protected override DependencyObject CreateShell()
        {
            Shell shell = (Shell)Container.Resolve(typeof(Shell));
            shell.Container = Container;
            shell.Show();
            return shell;
        }

        protected override IUnityContainer CreateContainer()
        {
            return (IUnityContainer)InjectionBroker.GetInjectionContainer();
        }

        protected override void ConfigureContainer()
        {
            base.ConfigureContainer();
            /*
            Container.RegisterType<IInventoryItemProvider, InventoryItemAXProvider>();
            Container.RegisterType<IInventoryItemSalesParamProvider, InventoryItemSalesParamAXProvider>();
            Container.RegisterType<IInventoryBarCodeProvider, InventoryBarCodeAXProvider>();
            Container.RegisterType<ICustomerProvider, CustomerAXProvider>();
            Container.RegisterType<ISaleInvoiceProvider, SaleInvoiceAXProvider>();
            Container.RegisterType<ICreateSaleInvoice, AxCreateSaleInvoice>();
            */
            Container.RegisterType<IInventoryItemProvider, InventoryItemWCFProxyProvider>();
            Container.RegisterType<IInventoryItemSalesParamProvider, InventoryItemSalesParamWCFProxyProvider>();
            Container.RegisterType<IInventoryBarCodeProvider, InventoryBarCodeWCFProxyProvider>();
            Container.RegisterType<ICustomerProvider, CustomerWCFProxyProvider>();
            Container.RegisterType<ISaleInvoiceProvider, SaleInvoiceWCFProxyProvider>();
            Container.RegisterType<ICreateSaleInvoice, WcfCreateSaleInvoice>();

            Container.RegisterType<IInventoryItemCache<IInventoryItemData>, InventoryItemCache>();
            Container.RegisterType<IInventoryItemService, InventoryItemService>();

            Container.RegisterType<IInventoryItemSalesParamCache<IInventoryItemSalesParamData>, InventoryItemSalesParamCache>();
            Container.RegisterType<IInventoryItemSalesParamService, InventoryItemSalesParamService>();

            Container.RegisterType<IInventoryBarCodeCache<IInventoryBarCodeData>, InventoryBarCodeCache>();
            Container.RegisterType<IInventoryBarCodeService, InventoryBarCodeService>();

            Container.RegisterType<ICustomerShoppingCartProvider, CustomerShoppingCartPICProvider>();
            Container.RegisterType<ICustomerShoppingCartModel, CustomerShoppingCartModel>();
            Container.RegisterType<ICustomerShoppingCartService, CustomerShoppingCartService>();//new ContainerControlledLifetimeManager());
            Container.RegisterType<ICustomerShoppingCartView, CustomerShoppingCartView>();

            Container.RegisterType<ICustomerShoppingCartItemProvider, CustomerShoppingCartItemPICProvider>();
            Container.RegisterType<ICustomerShoppingCartItemModel, CustomerShoppingCartItemModel>();
            Container.RegisterType<ICustomerShoppingCartItemListModel, CustomerShoppingCartItemListModel>();
            Container.RegisterType<ICustomerShoppingCartItemService, CustomerShoppingCartItemService>();//new ContainerControlledLifetimeManager());
            Container.RegisterType<ICustomerShoppingCartItemListView, CustomerShoppingCartGrid>();

            Container.RegisterType<ICustomerCache<ICustomerData>, CustomerCache>();
            Container.RegisterType<ICustomerService, CustomerService>();

            Container.RegisterType<ICustomerModel, CustomerModel>();
            Container.RegisterType<ICustomerSearchModel, CustomerSearchModel>();
            Container.RegisterType<ICustomerListModel, CustomerListModel>();

            Container.RegisterType<ICustomerInfoView, CustomerInfoView>();
            Container.RegisterType<ICustomerSearchView, CustomerSearchView>();
            Container.RegisterType<ICustomerListView, CustomerListView>();

            Container.RegisterType<ISaleInvoiceCache<ISaleInvoiceData>, SaleInvoiceCache>();
            Container.RegisterType<ISaleInvoiceService, SaleInvoiceService>();

        }
    }
}
